package com.qing.microservices.shirostudy.service.impl;

import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.qing.microservices.shirostudy.entity.Authority;
import com.qing.microservices.shirostudy.entity.Role;
import com.qing.microservices.shirostudy.entity.RoleAuthority;
import com.qing.microservices.shirostudy.mapper.RoleMapper;
import com.qing.microservices.shirostudy.service.IAuthorityService;
import com.qing.microservices.shirostudy.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Q
 * @since 2023-06-06
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Resource
    private IAuthorityService authorityService;

    @Override
    public List<Authority> queryAuthorityList(List<Long> roleIds) {

        MPJLambdaWrapper<Authority> wrapper = new MPJLambdaWrapper<>();
        wrapper.selectAll(Authority.class)
                .innerJoin(RoleAuthority.class, RoleAuthority::getAuthorityId, Authority::getId)
                .in(RoleAuthority::getRoleId, roleIds);
        return authorityService.list(wrapper);
    }

}
